$(function(){
	$.extend($.fn.validatebox.defaults.rules, {
        minLength: {
            validator: function(value, param){
                return value.length >= param[0];
            },
            message: '长度不能小于{0}位'
        },
        maxLength: {
         validator: function(value,param){
         return value.length <=param[0];
         },
         message: '长度不能大于{0}位'
        }
    });
	var deleteUrl = currenthost + '/responsibility/delete.ajax';
	var addUpdateUrl = currenthost + '/responsibility/addOrUpdate.ajax';
	var gridId = "responsibility_table";
	var mygrid = $.LandRowEditGrid(gridId,deleteUrl,addUpdateUrl);
	mygrid.create.createGrid=createMyGrid();
	mygrid.create.createGrid();
})






function createMyGrid(){
	$("#"+myGrid.gridId).datagrid({
		url: currenthost + '/responsibility/query.ajax',
		title: '责任人信息',
		iconCls: 'icon-edit',
		pagination: true,
		fitColumns:true,
		pageSize: 10,
		pageList: [10, 20, 30],
		columns: [[{
			field: 'id',
			hidden: true
		},
		{
			field: 'gmtCreated',
			hidden: true
		},
		{
			field: 'company',
			title: '公司索引库',
			width:  100,
			editor:{
				type:'validatebox',
				options:{
					required:true
				}
			}
		},
		{
			field: 'processname',
			title: '公文种类',
			width:  100,
			editor:{
				type:'validatebox',
				options:{
					required:true
				}
			}
		},
		{
			field: 'detail',
			title: '明细',
			width:  100,
			editor:{
				type:'validatebox',
				options:{
					required:true
				}
			}
		},
		{
			field: 'numberword',
			title: '文号代字',
			width:  150,
			editor:{
				type:'validatebox',
				options:{
					required:true
				}
			}
		},
		{
			field: 'responsibility',
			title: '责任人',
			width:  150,
			editor:{
				type:'validatebox',
				options:{
					required:true
				}
			}
		}]],
		toolbar: [{
			text: '增加',
			iconCls: 'icon-add',
			handler: myGrid.append
		},
		'-', {
			text: '删除',
			iconCls: 'icon-remove',
			handler: myGrid.remove
		},
		'-', {
			text: '保存',
			iconCls: 'icon-save',
			handler: function() {
				myGrid.accept();
			}
		},
		'-', {
			text: '取消',
			iconCls: 'icon-undo',
			handler: function() {
				myGrid.reject();
			}
		}],
		onClickRow:myGrid.onClickRow,
		onDblClickRow:myGrid.onDblClickRow
	});
}


//查询
function admin_responsibility_searchFun() {
	$('#responsibility_table').datagrid('load', serializeObject($('#admin_responsibility_searchForm')));
}

//清空条件
function admin_responsibility_cleanFun() {
	$('#admin_responsibility_searchForm').form('clear');
}